#include "Train.h"

class Solution {
public:
    double QuickPow(double x, long long n)
    {
        if (n < 0) x = 1 / x, n = -n;
        double ans = 1;
        while (n)
        {
            if (n & 1) ans *= x;
            n >>= 1;
            x *= x;
        }
        return ans;
    }
    double myPow(double x, int n) { //n可能为负数
        double ans;
        long long N = n;
        ans = QuickPow(x, N);
        return ans;
    }
};



class Solution {
public:
    double QuickPow(double x, long long n)
    {
        if (n == 0) return 1.0;
        double tmp = QuickPow(x, n / 2);
        return n % 2 == 0 ? tmp * tmp : tmp * tmp * x;
    }
    double myPow(double x, int n) { //n可能为负数
        double ans;
        long long N = n;
        
        return N < 0 ? 1.0 / pow(x, -N) : pow(x, N);
    }
};